import json

from mrjob.job import MRJob
from mrjob.step import MRStep


class MovieMRJob(MRJob):
    def steps(self):
        return [
            MRStep(mapper=self.mapper, reducer=self.reducer)
        ]

    def mapper(self, key, value):
        try:
            movie_info = json.loads(value)
            rate = movie_info["rate"]
            title = movie_info["title"]
            playable = movie_info['playable']
            if rate > 7.5 and playable == "True":
                yield movie_info
        except Exception as e:
            pass

    def reducer(self, key, values):
        pass


if __name__ == '__main__':
    MovieMRJob.run()
